-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AMQ-9541 limit expensive queries on the database side #1275
base: activemq-5.18.x
Are you sure you want to change the base?
Conversation
|
||
PreparedStatement s = null; | ||
ResultSet rs = null; | ||
try { | ||
s = c.getConnection().prepareStatement(this.statements.getFindDurableSubMessagesByPriorityStatement()); | ||
s = c.getConnection().prepareStatement(this.limitQuery(this.statements.getFindDurableSubMessagesByPriorityStatement())); | ||
s.setMaxRows(Math.min(maxReturned * 2, maxRows)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why there is "* 2" for the setMaxRows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an expert, but I did some git blame digging, the * 2 got introduced in https://issues.apache.org/jira/browse/AMQ-2980, to take into account the messages from low and high priority queues, to ensure that none get lost and to not hog more memory than needed. Down the road this happened java.sql.SQLException: setMaxRows() out of range. 50871918 > 50000000.
(https://issues.apache.org/jira/browse/AMQ-1870). The solution to this was to pick the lowest of two values (maxReturner * 2) and maxRows
, to ensure such exception does not happen.
|
||
PreparedStatement s = null; | ||
ResultSet rs = null; | ||
try { | ||
s = c.getConnection().prepareStatement(this.statements.getFindDurableSubMessagesStatement()); | ||
s = c.getConnection().prepareStatement(this.limitQuery(this.statements.getFindDurableSubMessagesStatement())); | ||
s.setMaxRows(Math.min(maxReturned * 2, maxRows)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why there is "* 2" for the setMaxRows
…ere there is a setMaxRows on the statement.
743c91c
to
e66d2a0
Compare
…ere there is a setMaxRows on the statement.